﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
using System.Text;

namespace OPDSView
{
    public class OPDSCatalog
    {
        public string Href;
        public string Id;
        public string Title { get; set; } 
        public string Updated;
        public string Icon;
        public List<OPDSEntry> Entries ;
    }
    
    public class OPDSEntry
    {
        public string Updated;
        public string Id;
        public string Title;
        public string Content;
        public string Href;
        public string DownloadLinkFb2 = "";
        public string WebUrl = "";
        public string ImageUrl = "";
        public bool Downloadable = false;
        public List<OPDSEntry> Entries;
    }

    public class OPDSCatalogList
    {
        public void SaveCatalogList()
        {
            
        }

        public List<OPDSCatalog> GetCatalogList()
        {
            var catalogList = new List<OPDSCatalog>();

            var opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://coollib.com/opds";
            opdsCatalog.Title = "Cool Lib";
            opdsCatalog.Id = "CoolLib";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://flibusta.is/opds";
            opdsCatalog.Title = "Flibusta";
            opdsCatalog.Id = "Flibusta";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://fb.litlib.net";
            opdsCatalog.Title = "Lit Lib";
            opdsCatalog.Id = "LitLib";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://asmodei.ru/opds";
            opdsCatalog.Title = "Asmodei";
            opdsCatalog.Id = "admodei";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://iknigi.net/opds";
            opdsCatalog.Title = "iKnigi";
            opdsCatalog.Id = "iknigi";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://f-w.in/opds";
            opdsCatalog.Title = "Fantasy World";
            opdsCatalog.Id = "fantasyworld";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://www.e-reading.club/opds";
            opdsCatalog.Title = "E-Reading";
            opdsCatalog.Id = "ereading";
            catalogList.Add(opdsCatalog);

            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://maxima-library.org/opds";
            opdsCatalog.Title = "Maxima Library";
            opdsCatalog.Id = "maximalibrary";
            catalogList.Add(opdsCatalog);

            /*
            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://smartoff.net/opds";
            opdsCatalog.Title = "Android Club";
            opdsCatalog.Id = "androidclub";
            catalogList.Add(opdsCatalog);
       
             */

            /*
            opdsCatalog = new OPDSCatalog();
            opdsCatalog.Href = "http://fantlab.ru/opds";
            opdsCatalog.Title = "FantLab";
            opdsCatalog.Id = "fantlab";
            catalogList.Add(opdsCatalog);
             */
            


            return catalogList;
        }

        public void PopulateCatalogsComboBox(ComboBox combobox)
        {
            var catalogList = GetCatalogList();
            combobox.Items.Clear();

            //combobox.DataSource = new BindingSource(catalogList,null);
            combobox.DisplayMember = "Title";

            foreach (OPDSCatalog catalog in catalogList)
            {
                combobox.Items.Add(catalog);
            }

            combobox.SelectedIndex = 0;
        }
    }
}
